import requests,sys
sys.path.append("D:\\Day\\p2p")
from api.api_factory import ApiFactory
from tools import read_html


class TestFactory:
    def setup_method(self):
        self.session = requests.session()
        self.api = ApiFactory(self.session)
    def teardown_method(self):
        self.session.close()
    def test01_invest_list(self):
        # 1、获取图片验证码接口
        self.api.get_api_register_login().api_img_code(123123)
        # 2、获取短信验证码接口
        self.api.get_api_register_login().api_phone_code("19400001111","8888")
        # 3、注册接口
        self.api.get_api_register_login().api_register("19400001111","admin123","8888","666666","on","")
        # 4、登录接口
        self.api.get_api_register_login().api_login("19400001111","admin123")
        # 5、认证接口
        self.api.get_api_approve_trust().api_approve("萨子欣","330723199706279462")
        # 6、后台开户接口
        resp = self.api.get_api_approve_trust().api_trust()
        # 7、三方开户
        result = read_html(resp)
        print(result[0])
        self.session.post(url=result[0], data=result[1])
        # 8、充值验证码接口
        self.api.get_api_recharge().api_img_code(123123)
        # 9、后台充值接口
        resp = self.api.get_api_recharge().api_recharge()
        # 10、三方充值接口
        result = read_html(resp)
        print(result[0])
        self.session.post(url=result[0], data=result[1])
        # 11、后台投资接口
        resp = self.api.get_api_invest().api_invest(100)
        # 12、三方投资接口
        result = read_html(resp)
        print(result[0])
        self.session.post(url=result[0], data=result[1])